package com.gdatacloud.config;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;

public class U {

	public static Long getUserId() {
		Object o = SecurityUtils.getSubject().getPrincipal();
		if (o == null) {
			return null;
		}
		String userIdStr = o.toString();
		Long userId = Long.parseLong(userIdStr);
		return userId;
	}
	
	public static Integer getRoleId() {
		// 当验证都通过后，把用户信息放在session里
		Session session = SecurityUtils.getSubject().getSession();
		Object o = session.getAttribute("roleId");
		if (o != null) {
			int r = Integer.parseInt(o.toString());
			return r;
		}
		return 1;
	}
}
